package org.way.file.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.rocketmq.client.producer.SendResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.way.base.aop.Msg;
import org.way.base.dto.GlobalDTO;
import org.way.rocketMq.service.MqProducerService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@Api(tags = "测试")
public class RocketMqController {
    @Resource
    private MqProducerService producerService;

    private static final ThreadLocal<Map<String,Object>> threadLocal = new ThreadLocal<>();

    @ApiOperation("rocketMq消息")
    @GetMapping("/rocketMq")
    public GlobalDTO<SendResult> testRocketMq(String message) {
        producerService.sendMsg(message);
        producerService.senAsyncMsg(message);
        SendResult sendResult = producerService.sendSyncMsg(message);
        return GlobalDTO.success(sendResult);
    }

    @GetMapping("/store")
    @Msg(desc = "测试")
    public GlobalDTO<Integer> store(String id,String name) {
        System.out.println(Thread.currentThread().getId() + " " + Thread.currentThread().getName());
        return GlobalDTO.success();
    }
}
